import '_base_export.dart';

import 'app_util.dart';
import 'package:fluwx/fluwx.dart';
import 'package:firebase_messaging/firebase_messaging.dart';

class InitWork {
  static initSync() {
//Route
    final router = new FluroRouter();
    AppRoutes.configureRoutes(router);
    App.router = router;

    FirebaseMessaging messaging = FirebaseMessaging.instance;
  }

  static initAsync() async {
    await AppSession.init();

//TODO --- Firebase Crashlytics / Analytics initial

    // if ((AppSession?.appUtil?.staff ?? {}).isNotEmpty) {
    // await AppAnalytics.analytics.setUserId(AppSession?.appUtil?.staff['merchant_id'].toString());
    // await AppAnalytics.analytics.setUserProperty(
    //     name: 'staff_id', value: AppSession?.appUtil?.staff['merchant_id'].toString());

    // FirebaseCrashlytics.instance.setUserIdentifier(
    //     AppSession?.appUtil?.staff['merchant_id'].toString() +
    //         ' - ' +
    //         AppSession?.appUtil?.staff['staff_id'].toString());
    // // }
    // }

    // final app_util = new AppUtil();
    // await app_util.initLoad();
    await Intercom.initialize(
      App3rdKey.intercom_appid,
      iosApiKey: App3rdKey.intercom_ios,
      androidApiKey: App3rdKey.intercom_android,
    );
    await registerWxApi(appId: App3rdKey.wechat_appid, universalLink: App3rdKey.wechat_ulink);

    var lv_wxIns = await isWeChatInstalled;
    AppSession.setWeChatIns(lv_wxIns);
  }
}
